package com.cn.wanxi.service;

import com.cn.wanxi.dao.NavDao;
import com.cn.wanxi.model.NavModel;

public class NavService {
    /**
     * 封装导航需要的数据
     *
     * @return
     */
    public NavModel[] getNavModels() {
//        新建一个数组，装数据，返回给servlet 只定义了长度，没有定义内容
        NavDao navDao = new NavDao();
        int length = navDao.hrefs.length;
        NavModel[] navModels = new NavModel[length];
        for (int i = 0; i < length; i++) {
            NavModel model = new NavModel();
            model.setHref(navDao.hrefs[i]);
            model.setTitle(navDao.titles[i]);
            navModels[i] = model;
        }
//        NavModel model1 = new NavModel();
//        model1.setHref(navDao.a1);
//        model1.setTitle("b1");
//        navModels[0] = model1;
//
//        NavModel model2 = new NavModel();
//        model2.setHref("a2");
//        model2.setTitle("b2");
//        navModels[1] = model2;
//
//        NavModel model3 = new NavModel();
//        model3.setHref("a3");
//        model3.setTitle("b3");
//        navModels[2] = model3;
        return navModels;
    }

    public static void main(String[] args) {
        new NavService().getNavModels();
    }
}
